<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="beans.ChatMessagebean"%>
<%@page import="dao.Chatmessage"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>
<%	
	String messageid = null;
	String des = null;
	Chatmessage chatmessage = null;
	if(request.getQueryString() !=null){
	    messageid = request.getParameter("id").trim();
	    des = request.getParameter("des").trim();
	    int id = Integer.parseInt(messageid);
	    chatmessage = new ChatMessagebean().findMessageById(id);
	}
	DateFormat formater = new SimpleDateFormat("yyyy年MM月dd日 hh:MM:ss");
	String time = formater.format(chatmessage.getSendtime());
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>回复留言</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet" type="text/css" href="./clEditer/jquery.cleditor.css" />
<style type="text/css">
body {
	font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: center;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 650px;
	height: 400px;
	background: #f8f8f8;
	border: 2px solid #777;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 30px;
	margin-botton: 10px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
<script type="text/javascript" src="./clEditer/jquery.min.js"></script>
<script type="text/javascript" src="./clEditer/jquery.cleditor.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#messageContext").cleditor();       
      });
    function checkData(){
    	var context = document.getElementById("messageContext").value.trim();	
    	if( context !="" ){
    		return true;
    	}else{
    		alert("回复内容不能为空！");
    		return false;
    	}  	
    }
 </script>
</head>
<body>
	<form name="addMessageForm" action="./servlet/MessageManagerServlet?action=reply" method="post"
		onsubmit="return checkData()">
		<input type="hidden" name="messageid" id="messageid" value="<%=messageid %>">
		<input type="hidden" name="des" id="des" value="<%=des %>">
		<div id="container">
			<div class="ele">
			<label>来源：</label><%=chatmessage.getSource() %><br>
			<label>发送时间：</label><%=time %><br>
			<label>留言类型：</label><%=chatmessage.getMessagetype() %><br>
			<label>留言内容：</label><%=chatmessage.getMessage() %><br>			
			</div>
			<div class="ele">
				<label> 回复内容： </label>
				<textarea rows="7" cols="65" id="messageContext"
					name="messageContext"></textarea>
			</div>
			<div class="ele">
				<input type="submit" value="提交"> <input type="reset"
					value="取消">
			</div>
		</div>
	</form>
	<%
	    if (request.getAttribute("success") != null) {
			String str = (String) request.getAttribute("success");
			if ("false".equals(str)) {
			    out.write("<script>alert('添加失败！')</script>");
			}
	    }
	%>
</body>
</html>
